﻿using HybridLab.Virtual.Interfaces;
using Microsoft.TeamFoundation.Lab.Client;
using Microsoft.TeamFoundation.Lab.Workflow.Activities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HybridLab.Workflow.Activities.Info
{
	[Serializable]
	public class HybridLabEnvironment : IEquatable<HybridLabEnvironment>
	{
		private Guid id;

		public LabEnvironmentDetails LabEnvironment { get; set; }

		public bool RevertToSnapshot { get; set; }

		public string HostType { get; set; }

		public string HostName { get; set; }

		public HybridLabHostCredentials Credentials { get; set; }

		public HybridLabEnvironmentSnapshotInfo EnvironmentSnapshotInfo { get; set; }

		public string InteractiveUserPassword { get; set; }

		public HybridLabEnvironment()
		{
			id = Guid.NewGuid();
			EnvironmentSnapshotInfo = new HybridLabEnvironmentSnapshotInfo();
		}

		public HybridLabEnvironment(IVirtualHost host)
			: this()
		{
			if (host != null)
			{
				Credentials = new HybridLabHostCredentials()
				{
					DomainName = host.Domain,
					UserName = host.UserName,
					Password = host.Password
				};
				HostName = host.HostName;
				HostType = host.HostType;
			}
		}

		public bool Equals(HybridLabEnvironment other)
		{
			return LabEnvironment == other.LabEnvironment && HostType == other.HostType && HostName == other.HostName && EnvironmentSnapshotInfo.Snapshots.Count == other.EnvironmentSnapshotInfo.Snapshots.Count;
		}

		public override int GetHashCode()
		{
			return id.GetHashCode();
		}
	}
}
